<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>定义Promise类并绑定this</title>
  <script src="./promise.js"></script>
</head>
<body>
  <ul>
    <li>定义Promise构造函数以及resolve,reject，但存在两个问题</li>
    <li>首先this在resolve或reject内部无法获取到(原因是类是默认严格模式，this在(嵌套)函数作用域下是undefined)，可使用箭头函数或bind解决(已解决)</li>
    <li>其次resolve,reject同时改变Promise状态是不允许的(未解决)</li>
  </ul>
  <script>
    const promise = new MyPromise((resolve, reject) => {
      resolve('success')
      reject('fail')
    })
    console.log(promise)
  </script>
</body>
</html>